if [ ! -d ${SYSDIR}/cross-tools/rust ]; then
	wget https://static.rust-lang.org/dist/rust-1.88.0-x86_64-unknown-linux-gnu.tar.gz
	tar xf rust-1.88.0-x86_64-unknown-linux-gnu.tar.gz
	pushd rust-1.88.0-x86_64-unknown-linux-gnu
	    ./install.sh --destdir=${SYSDIR}/cross-tools/rust
	popd
fi

tar xf ${DOWNLOADDIR}/rustc-1.89.0-src.tar.gz -C ${BUILDDIR}
pushd ${BUILDDIR}/rustc-1.89.0-src
    ./configure --target=${CROSS_TARGET},$(echo ${CROSS_HOST} | sed 's@cross@unknown@g') \
                --prefix=${SYSDIR}/cross-tools --sysconfdir=${SYSDIR}/cross-tools/etc \
                --local-rust-root=${SYSDIR}/cross-tools/rust/usr/local \
                --enable-extended --enable-vendor --disable-docs --disable-dist-src --release-channel=dev \
                --disable-codegen-tests --experimental-targets="" --enable-llvm-static-stdcpp --enable-profiler \
                --set=target.${CROSS_TARGET}.linker="${CROSS_TARGET}-gcc" \
                --set=target.${CROSS_TARGET}.cc="${CROSS_TARGET}-gcc" \
                --set=target.${CROSS_TARGET}.cxx="${CROSS_TARGET}-g++" \
                --set=target.${CROSS_TARGET}.llvm-config="${CROSS_TARGET}-llvm-config" \
                --set=target.$(echo ${CROSS_HOST} | sed 's@cross@unknown@g').llvm-config="${SYSDIR}/cross-tools/bin/llvm-config"
    export CARGO_TARGET_$(echo ${CROSS_TARGET^^} | tr '-' '_')_LINKER="${CROSS_TARGET}-gcc"
    export CARGO_TARGET_$(echo ${CROSS_TARGET^^} | tr '-' '_')_RUSTFLAGS="-Ccode-model=large"
    make HOST_CC="gcc" ${JOBS}
    make HOST_CC="gcc" install
    unset CARGO_TARGET_$(echo ${CROSS_TARGET^^} | tr '-' '_')_LINKER
    unset CARGO_TARGET_$(echo ${CROSS_TARGET^^} | tr '-' '_')_RUSTFLAGS
popd
